﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General

Namespace DoAnQuanLyBanHang.DTO
    Public Class PhanQuyenData
        Private m_PhanQuyenData As New DataService()

        Public Function LayPhanQuyen() As DataTable
            Dim cmd As New SqlCommand("SELECT * FROM Phan_Quyen")
            m_PhanQuyenData.Load(cmd)
            Return m_PhanQuyenData
        End Function

        Public Function LayPhanQuyen(m_Name As [String]) As DataTable
            Dim cmd As New SqlCommand("SELECT * FROM Phan_Quyen WHERE TenDangNhap = @m_Name")
            cmd.Parameters.Add("m_Name", SqlDbType.VarChar).Value = m_Name

            m_PhanQuyenData.Load(cmd)
            Return m_PhanQuyenData
        End Function

        Public Function ThemDongMoi() As DataRow
            Return m_PhanQuyenData.NewRow()
        End Function

        Public Sub ThemPhanQuyen(m_Row As DataRow)
            m_PhanQuyenData.Rows.Add(m_Row)
        End Sub

        Public Function LuuPhanQuyen() As Boolean

            Return m_PhanQuyenData.ExecuteNoneQuery() > 0
        End Function

#Region "doi mat khau"
        Public Sub DoiMatKhau(TenDN As [String], MatKhauMoi As [String])
            m_PhanQuyenData.DoiMatKhau(TenDN, MatKhauMoi)
        End Sub
#End Region
    End Class
End Namespace
